package com.lsy.on_line;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.Collections;

public class Generator {

    @Test
    public void test() {
        FastAutoGenerator.create("jdbc:mysql://101.42.246.22:3306/zaixian", "root", "Zrrd2113@Yg")
                .globalConfig(builder -> {
                    builder.author("ShiYuan") // 设置作者
                            .enableSwagger() // 开启 swagger 模式
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("C:\\Dev\\Workspace\\JavaSpace\\Idea-Workspace\\on_line\\src\\main\\java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.lsy.on_line") // 设置父包名
                            .moduleName("zaixian") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, "C:\\Dev\\Workspace\\JavaSpace\\Idea-Workspace\\on_line\\src\\main\\resources")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("chapter","episode","user","video","video_banner","video_order") // 设置需要生成的表名
                            .addTablePrefix("video_"); // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();

    }
}
